﻿using UnityEngine;
using Newtonsoft.Json;

public enum CompileType
{
	dev,
	alpha,
	beta,
	release
}



public class VersionInfo
{
    public CompileType compile_type = CompileType.dev;
	public string version = "1.0.0";
	public int version_number = 0;
	public int build_number = 0;
	public ulong build_time = 0;
}

public static class VersionEx
{
	public static VersionInfo versionInfo;

	private static void init()
	{
		if(versionInfo == null)
		{
//			string str = DecompressLocalBundleManager.getLocalResString("version.txt");

            TextAsset versionAsset = Resources.Load<TextAsset>("version");
            if (versionAsset != null)
            {
                string str = versionAsset.text;
                versionInfo = JsonConvert.DeserializeObject<VersionInfo>(str);
            }
            else
            {
                versionInfo = new VersionInfo();
            }
		}
	}

    public static CompileType compile_type
    {
        get
        {
            init();
            return versionInfo.compile_type;
        }
    }
    

	public static string version
	{
		get
		{
			init();
			return versionInfo.version;
		}
	}

	public static int version_number
	{
		get
		{
			init();
			return versionInfo.version_number;
		}
	}

	public static int build_number
	{
		get
		{
			init();
			return versionInfo.build_number;
		}
	}

	public static ulong build_time
	{
		get
		{
			init();
			return versionInfo.build_time;
		}
	}
}
